from typing import Optional
from pydantic import BaseModel
from pydantic.fields import Field
from application.entity import BaseOutEntity
from application.entity.UserEntity import UserSearchOut
from application.enumeration.ContentTypeEnum import ContentTypeEnum


class CommentAdd(BaseModel):
    """
    评论添加
    """
    content: str = Field(min_length=1, max_length=280, description="评论内容，长度280")
    target_id: int = Field(description="目标ID")
    content_type: ContentTypeEnum = Field(default=ContentTypeEnum.NOTE,
                                          description="评论内容类型，枚举：帖子等等，默认为帖子")


class CommentReplyAdd(BaseModel):
    """
    回复评论添加
    """
    comment_id: int = Field(description="回复的评论ID/父评论ID，不能为空")
    depth: int = Field(default=1, description="回复深度，1级、2级，默认1级")
    content: str = Field(min_length=1, max_length=280, description="评论内容，长度280")


class CommentBaseOut(BaseOutEntity):
    """
    评论输出基类
    """
    content: Optional[str] = None
    user_info: Optional[UserSearchOut] = None
    is_disabled: Optional[bool] = None


class CommentReplyOut(CommentBaseOut):
    """
    回复评论输出
    """
    comment_id: int = Field(description="回复的评论ID/父评论ID，不能为空")
    depth: int = Field(default=1, description="回复深度，1级、2级，默认1级")


class CommentOut(CommentBaseOut):
    """
    评论输出
    """
    reply_list: list[Optional[CommentReplyOut]] = Field(default=[], description="回复列表，这里只显示5个")


